﻿#pragma once
#include "GlesContext.h"
#include "EglContext.h"

enum class RenderType
{
	fit,	// 等比缩小放入画布
	fill	// 铺满画布
};

class RenderContext
{
public:
	RenderContext(EGLNativeWindowType wnd);
	~RenderContext();

	/** 绘制 */
	void draw();

	/** 更新纹理 */
	void updateImage(void* buffer[], int width, int height);

	/** 设置画面拉伸方式 */
	void setRenderType(RenderType renderType);

	GlesContext* glesContext()
	{
		return _glesContext;
	}

	EglContext* eglContext()
	{
		return _eglContext;
	}

private:
	GlesContext* _glesContext;
	EglContext* _eglContext;
	EGLNativeWindowType _wnd;

	long _windowsWidth;
	long _windowsHeight;

	int _imageWidth;
	int _imageHeight;

	/** 画面拉伸方式 */
	RenderType _renderType;

	/** 更新渲染区域 */
	void updateRenderSize();
};